package com.qianfeng.exam.controller;

import com.qianfeng.exam.dto.R;
import com.qianfeng.exam.pojo.Categories;
import com.qianfeng.exam.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private ICategoryService categoryService;
    @Autowired
    private Categories categories;
    @PostMapping("/newcategory/{categoryName}")
    public R addCategory (@PathVariable("categoryName") String categoryName){
        categories.setCategoryname(categoryName);
        categoryService.addCategory(categories);
        return R.setOk(categories,"添加图书分类成功");
    }
}
